/*
	创建并使用连接池对象
*/

var mysql = require('mysql');

var pool = mysql.createPool({
	host: 'localhost',
	port: 3306,
	database: 'test',
	user: 'root',
	password: '123456'
});


pool.getConnection(function(err, connection){
	if(err)
		console.log("连接失败");
	else{
		console.log("连接成功");
		connection.query('select * from users', function(err, rows){
			if(err)
				console.log("查询失败");
			else{
				console.log(rows);
				pool.end();
			}
		})
	}
});
